home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Angled Carets and Hilites.c next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.9 KB  |  115 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     1.0D2 ???    change transfer modes from gxXorMode to gxFastXorMode
  5.                 and change SetShapeCommonTransfer to SetShapeFastTransfer
  6.  
  7.     ©1990 - 1996  Apple Computer, Inc.
  8.     All rights reserved.
  9. ****************************************************************************************************/
  10.  
  11. #include <Types.h>
  12. #include <QuickDraw.h>
  13. #include <Fonts.h>
  14. #include <Windows.h>
  15. #include <Menus.h>
  16. #include <SegLoad.h>
  17. #include <Memory.h>
  18. #include <Desk.h>
  19.  
  20. #include <GXGraphics.h>
  21. #include "GraphicsLibraries.h"
  22. #include <GXEnvironment.h>
  23.  
  24. #include <GXTypes.h>
  25. #include <GXLayout.h>
  26. #include "LayoutLibrary.h"
  27.  
  28. #include "SampleInterface.h"
  29.  
  30. short MyStrLen(char *x);
  31. static short MyStrLen(x)
  32. char    *x;
  33.     {
  34.     short c = 0;
  35.     while (*x++) c++;
  36.     return c;
  37.     }    /* MyStrLen */
  38.  
  39. void AngledCaretsAndHilites(WindowPtr sampleWindow)
  40.     {
  41.     /* Variables */
  42.     char            *myString = "Intrinsically Angled Text";
  43.     gxPoint            myPoint;
  44.     gxRunControls        gxRunControls;
  45.     gxShape            caret, highlight, layout;
  46.     short            i, len, level = 0;
  47.     gxStyle            myStyle;
  48.     gxViewPort        aViewPort;
  49.     
  50.     /* Initialization */
  51.     
  52.     myPoint.x = ff(20);
  53.     myPoint.y = ff(50);
  54.     
  55.     aViewPort = GXNewWindowViewPort(sampleWindow);
  56.     SetDefaultViewPort(aViewPort);
  57.     
  58.     len = MyStrLen(myString);
  59.     InitializeRunControls(&gxRunControls);
  60.  
  61.     myStyle = NewLayoutStyle((char *) "\pZapf Chancery Medium Italic", ff(50), 0, nil, nil, 0, nil);
  62.     
  63.     layout = GXNewLayout(
  64.         1, &len, (void *) &myString,
  65.         1, &len, &myStyle,
  66.         1, &len, &level,
  67.         nil, &myPoint);
  68.     GXDrawShape(layout);
  69.     
  70.     for (i = 0; i <= len; i++)
  71.         {
  72.         caret = GXGetLayoutCaret(layout, i, gxHighlightAverageAngle, gxSplitCaretType, nil);
  73.         GXDrawShape(caret);
  74.         GXDisposeShape(caret);
  75.         }
  76.     
  77.     gxRunControls.flags = gxNoCaretAngle;
  78.     GXSetStyleRunControls(myStyle, &gxRunControls);
  79.     GXMoveShape(layout, 0, ff(75));
  80.     GXDrawShape(layout);
  81.     
  82.     for (i = 0; i <= len; i++)
  83.         {
  84.         caret = GXGetLayoutCaret(layout, i, gxHighlightAverageAngle, gxSplitCaretType, nil);
  85.         GXDrawShape(caret);
  86.         GXDisposeShape(caret);
  87.         }
  88.     
  89.     gxRunControls.flags = 0;
  90.     GXSetStyleRunControls(myStyle, &gxRunControls);
  91.     GXMoveShape(layout, 0, ff(75));
  92.     GXDrawShape(layout);
  93.     
  94.     highlight = GXGetLayoutHighlight(layout, 5, 11, gxHighlightAverageAngle, nil);
  95.     /* changed to make this invert */
  96.     SetShapeFastXorTransfer(highlight, NULL, NULL);
  97.     GXDrawShape(highlight);
  98.     GXDisposeShape(highlight);
  99.     
  100.     gxRunControls.flags = gxNoCaretAngle;
  101.     GXSetStyleRunControls(myStyle, &gxRunControls);
  102.     GXMoveShape(layout, 0, ff(75));
  103.     GXDrawShape(layout);
  104.     
  105.     highlight = GXGetLayoutHighlight(layout, 5, 11, gxHighlightAverageAngle, nil);
  106.     /* changed to make this invert */
  107.     SetShapeFastXorTransfer(highlight, NULL, NULL);
  108.     GXDrawShape(highlight);
  109.     GXDisposeShape(highlight);
  110.     
  111.     GXDisposeShape(layout);
  112.     GXDisposeStyle(myStyle);
  113.     GXDisposeViewPort(aViewPort);
  114.     }    /* main */
  115.